package org.example.leetCode;

import java.util.Arrays;

public class twoSum2 {
    public static void main(String[] args) {
        int[] nums ={3,24,50,79,88,150,345};
        int[] ints = twoSum(nums, 200);
        System.out.println(Arrays.toString(ints));
    }

    public static int[] twoSum(int[] numbers, int target) {
        int left =0;
        int right = numbers.length-1;
        while (left<right){
            if (numbers[left]+numbers[right]==target){
                return new int[]{left+1,right+1};
            }else if (numbers[left]+numbers[right]>target){
                right--;
            }else {
                left++;
            }
        }
        return null;
    }
}
